package com.bytes32.stats;

import org.apache.hadoop.io.Writable;

/**
 * Represents a buffer used for holding approximate quantiles
 * @author murariuf
 *
 */
public interface QBuffer extends Writable{
	/**
	 * Sets the weight of the buffer
	 * @param weight
	 */
	public void weight(int weight);
	
	/**
	 * Gets the weight of the buffer
	 * @return
	 */
	public int weight();
	
	/**
	 * Sets the level of the buffer
	 * @param level
	 */
	public void level(int level);
	
	/**
	 * Returns the level of the buffers
	 * @return
	 */
	public int level();
	
	/**
	 * Sets the buffer status
	 * @param status
	 */
	public void status(BufferStatus status);
	
	/**
	 * Returns the buffer status
	 * @return
	 */
	public BufferStatus status();
	
	/**
	 * Returns the buffer length
	 * @return
	 */
	public int getLength();
	
	/**
	 * Returns the buffer maximum length
	 * @return
	 */
	public int getMaxLength();
	
	/**
	 * Clears the buffer and resets everything
	 */
	public void clear();
	/**
	 * Sorts the buffer but leaves the 0.0 at the end
	 */
	public void sort();
	
	/**
	 * Returns a clone of the internal double[]
	 * @return
	 */
	public double[] toArray();
	
	/**
	 * adds a value to the buffer
	 * @param value
	 * @return
	 *  FULL if the buffer is now full or PARTIAL if the buffer still has space
	 */
	public BufferStatus add(final double value);
	
	/**
	 * Returns one value at index i from the buffer
	 * @param i
	 * @return
	 */
	public double get(int i);
}
